<%@page import="org.omg.CORBA.Request"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="java.sql.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Kết quả tìm kiếm</title>
</head>
<body bottomMargin=0 leftMargin=0
topMargin=0 rightMargin=0>
	<TABLE width="1024" height="768" border=0 cellSpacing=0 cellPadding=0 align=center>
	<TR HEIGHT="150">
	<TD Align=center colspan=5>
	<%@include file="top.jsp"%>
	</TD>
	</TR>
	
	<!---Khai báo khoảng phân cách--->
	<TR HEIGHT="2">
	<TD colspan=5 bgcolor="white"></TD>
	</TR>
	
	<TR HEIGHT=100%>
	<TD vAlign="top" width="150">
	<%@include file="left.jsp"%>
	</TD>
	
	<!---Khai báo khoảng phân cách--->
	<TD bgcolor=white width="2"></TD>
	<TD vAlign=top width="720" bgcolor=white>
<%
	String customer_card = request.getParameter("customer_card");
	String in_date = request.getParameter("in_date");
	String out_date = request.getParameter("out_date");
	String query = "select * from history where customer_card = "+customer_card+" AND (in_date>'"+in_date+"' and out_date >='"+in_date+"')";
	Class.forName("com.mysql.jdbc.Driver");
	Connection con = null;
	Statement smt = null;
	ResultSet rst = null;
	int i = 0;
	try {
		String username = "root";
		String password = "Vietyeutam1112";
		String url = "jdbc:mysql://127.0.0.1:3306/ghmotel";
		con = DriverManager.getConnection(url, username, password);
		smt = con.createStatement();
		rst = smt.executeQuery(query);
		out.print("<table width="+"720"+" height="+"100%"+" border="+"0"+">");
		if (!rst.next()) out.println("<tr><td>Không có kết quả</td></tr>");
		else rst.beforeFirst();
		out.println("<td><table border="+"1"+" width=1024 align=left>");
		out.println("<tr><td width=10% align=left>Tên phòng</td><td width=10% align=left>Tên khách hàng</td>");
		out.println("<td width=10% align=left>Số lượng</td>");
		out.println("<td width=10% align=left>Giờ vào</td>");
		out.println("<td width=10% align=left>Giờ ra </td>");
		out.println("<td width=10% align=left>Ngày sử dụng</td>");
		out.println("<td width=10% align=left>Giờ sử dụng</td>");
		out.println("<td width=10% align=left>Tiền phòng</td>");
		out.println("<td width=10% align=left>Tiền dịch vụ</td>");
		out.println("<td width=10% align=left>Tổng</td></tr>");
		while (rst.next()) {
			out.print("<tr>");		
			out.println("<td width=10% align=left>"+rst.getString(1)+"</td>");
			out.println("<td width=10% align=left>"+rst.getString(2)+"</td>");
			out.println("<td width=10% align=left>"+rst.getString(3)+"</td>");
			out.println("<td width=10% align=left>"+rst.getString(4)+"</td>");
			out.println("<td width=10% align=left>"+rst.getString(5)+"</td>");
			out.println("<td width=10% align=left>"+rst.getString(6)+"</td>");
			out.println("<td width=10% align=left>"+rst.getString(7)+"</td>");
			out.println("<td width=10% align=left>"+rst.getString(8)+"</td>");
			out.println("<td width=10% align=left>"+rst.getString(9)+"</td>");
			out.println("<td width=10% align=left>"+rst.getString(10)+"</td>");
			out.print("</tr>");
		}
		out.print("</table>");
		con.close();
	} catch (Exception e) {}
%>

	</TD>
	
	<!---Khai báo khoảng phân cách--->
	<TD bgcolor=white width="2"></TD>
	<TD vAlign=top width="150">
	<%@include file="right.jsp"%>
	</TD>
	</TR>
	
	<!---Khai báo khoảng phân cách--->
	<TR HEIGHT="2">
	<TD colspan=5 bgcolor=white></TD>
	</TR>
	
	<TR HEIGHT="50">
	<TD colspan=5 align=center>
	<%@include file="bottom.jsp"%>
	</TD>
	</TR>
	</TABLE>
</body>
</html>